/*
 * MassSpectrometerStateEventTest.java
 * JMUnit based test
 *
 * Created on 22-Nov-2009, 3:57:38 PM
 */

package ocbn.remotelab.test_package;


import ocbn.remotelab.events.*;
import java.util.Calendar;
import ocbn.remotelab.events.MassSpectrometerStateEvent.State;
import jmunit.framework.cldc10.*;
import ocbn.remotelab.util.date.Date;

/**
 * @author c9zhuron
 */
public class MassSpectrometerStateEventTest extends TestCase {
    private long id = 67889;
    private State stateC = State.COMPLETED;
    private String source = "source of the event";
    private Date time;
    private String detail = "Detail of the event";
    private static final String DEFAULT_SOURCE = "unknown mass spectrometer";
    private static final State DEFAULT_STATE = State.UNKNOWN;
    Calendar cal;
    String dateString;
    MassSpectrometerStateEvent mass1;
    MassSpectrometerStateEvent mass2;
    MassSpectrometerStateEvent mass3;
    MassSpectrometerStateEvent mass4;
    MassSpectrometerStateEvent mass5;
    MassSpectrometerStateEvent mass6;

    public MassSpectrometerStateEventTest() {
        //The first parameter of inherited constructor
        //is the number of test cases
        super(8,"MassSpectrometerStateEventTest");

        cal = Calendar.getInstance();
        cal.set(Calendar.YEAR, 2009);
        cal.set(Calendar.MONTH, 9);
        cal.set(Calendar.DAY_OF_MONTH, 3);
        cal.set(Calendar.HOUR_OF_DAY, 10);
        cal.set(Calendar.MINUTE, 12);
        cal.set(Calendar.SECOND, 0);
        dateString = "Oct 3, 2009 10:12:00 AM";

        mass1 = new MassSpectrometerStateEvent(id,stateC,source,time, detail);
        mass2 = new MassSpectrometerStateEvent(id,stateC,source,time);
        mass3 = new MassSpectrometerStateEvent(id,stateC,source);
        mass4 = new MassSpectrometerStateEvent(id,stateC);
        mass5 = new MassSpectrometerStateEvent(id);
        mass6 = new MassSpectrometerStateEvent();


    }

    public void test(int testNumber) throws Throwable {
        switch (testNumber) {
            case 0:
                testGetSummary();
                break;
            case 1:
                testGetSource();
                break;
            case 2:
                testGetDetails();
                break;
            case 3:
                testToString();
                break;
            case 4:
                testSetDetails();
                break;
            case 5:
                testSetSource();
                break;
            case 6:
                testSetState();
                break;
            case 7:
                testGetState();
                break;
            default:
                break;
        }
    }

    /**
     * Test of testGetSummary method, of class MassSpectrometerStateEvent.
     */
    public void testGetSummary() throws AssertionFailedException {
//
//        mass2 = new MassSpectrometerStateEvent(id,stateC,source,time);
//        mass3 = new MassSpectrometerStateEvent(id,stateC,source);
//        mass4 = new MassSpectrometerStateEvent(id,stateC);
//        mass5 = new MassSpectrometerStateEvent(id);
//        mass6 = new MassSpectrometerStateEvent();
        System.out.println("getSummary");
        assertEquals(State.COMPLETED + " on " + source + ". ",
                mass1.getSummary());
        assertEquals(State.COMPLETED  + " on " + source + ". ",
                mass2.getSummary());
        assertEquals(State.COMPLETED  + " on " + source + ". ",
                mass3.getSummary());
        assertEquals(State.COMPLETED  + " on " + DEFAULT_SOURCE + ". ",
                mass4.getSummary());
        assertEquals(DEFAULT_STATE + " on " + DEFAULT_SOURCE + ". ",
                mass5.getSummary());
        assertEquals(DEFAULT_STATE + " on " + DEFAULT_SOURCE + ". ",
                mass6.getSummary());
        //fail("The test case is a prototype.");
    }

    /**
     * Test of testGetSource method, of class MassSpectrometerStateEvent.
     */
    public void testGetSource() throws AssertionFailedException {
        System.out.println("getSource");
        assertEquals(source, mass1.getSource());
        assertEquals(source, mass2.getSource());
        assertEquals(source, mass3.getSource());
        assertEquals(DEFAULT_SOURCE, mass4.getSource());
        assertEquals(DEFAULT_SOURCE, mass5.getSource());
        assertEquals(DEFAULT_SOURCE, mass6.getSource());
        //fail("The test case is a prototype.");
    }

    /**
     * Test of testGetDetails method, of class MassSpectrometerStateEvent.
     */
    public void testGetDetails() throws AssertionFailedException {
        System.out.println("getDetails");
        assertEquals(detail, mass1.getDetails());
        assertEquals(mass2.getSummary(), mass2.getDetails());
        assertEquals(mass3.getSummary(), mass3.getDetails());
        assertEquals(mass4.getSummary(), mass4.getDetails());
        assertEquals(mass5.getSummary(), mass5.getDetails());
        assertEquals(mass6.getSummary(), mass6.getDetails());
        //fail("The test case is a prototype.");
    }

    /**
     * Test of testToString method, of class MassSpectrometerStateEvent.
     */
    public void testToString() throws AssertionFailedException {
        System.out.println("toString");
        assertEquals(mass1.getSummary(), mass1.toString());
        assertEquals(mass2.getSummary(), mass2.toString());
        assertEquals(mass3.getSummary(), mass3.toString());
        assertEquals(mass4.getSummary(), mass4.toString());
        assertEquals(mass5.getSummary(), mass5.toString());
        assertEquals(mass6.getSummary(), mass6.toString());
        //fail("The test case is a prototype.");
    }

    /**
     * Test of testSetDetails method, of class MassSpectrometerStateEvent.
     */
    public void testSetDetails() throws AssertionFailedException {
        System.out.println("setDetails");
        MassSpectrometerStateEvent instance = new MassSpectrometerStateEvent();
        instance.setDetails(detail);
        assertEquals(detail, instance.getDetails());

        //fail("The test case is a prototype.");
    }

    /**
     * Test of testSetSource method, of class MassSpectrometerStateEvent.
     */
    public void testSetSource() throws AssertionFailedException {
        System.out.println("setSource");
        MassSpectrometerStateEvent instance = new MassSpectrometerStateEvent();
        instance.setSource(source);
        assertEquals(source, instance.getSource());
        //fail("The test case is a prototype.");
    }

    /**
     * Test of testSetState method, of class MassSpectrometerStateEvent.
     */
    public void testSetState() throws AssertionFailedException {
        System.out.println("setState");
        MassSpectrometerStateEvent instance = new MassSpectrometerStateEvent();
        instance.setState(State.COMPLETED);
        assertEquals(State.COMPLETED, instance.getState());

        instance.setState(State.FAILED);
        assertEquals(State.FAILED, instance.getState());

        instance.setState(State.STARTED);
        assertEquals(State.STARTED, instance.getState());

        instance.setState(State.UNKNOWN);
        assertEquals(State.UNKNOWN, instance.getState());

        //fail("The test case is a prototype.");
    }

    /**
     * Test of testGetState method, of class MassSpectrometerStateEvent.
     */
    public void testGetState() throws AssertionFailedException {
        System.out.println("getState");
        MassSpectrometerStateEvent massC =
                new MassSpectrometerStateEvent(id,
                State.COMPLETED,source,time, detail);
        MassSpectrometerStateEvent massS =
                new MassSpectrometerStateEvent(id,
                State.STARTED,source,time, detail);
        MassSpectrometerStateEvent massF =
                new MassSpectrometerStateEvent(id,
                State.FAILED,source,time, detail);
        MassSpectrometerStateEvent massU =
                new MassSpectrometerStateEvent(id,
                State.UNKNOWN,source,time, detail);
        assertEquals(State.COMPLETED, massC.getState());
        assertEquals(State.STARTED, massS.getState());
        assertEquals(State.FAILED, massF.getState());
        assertEquals(State.UNKNOWN, massU.getState());

        //fail("The test case is a prototype.");
    }
}
